package com.example.controller;

import com.example.domain.User;
import com.example.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegisterController {

    @Autowired
    RegisterService registerService;

    @PostMapping("/register")
    public Result register(@RequestBody User user) {
        boolean flag = registerService.register(user);
        if (flag) {
            return Result.success(user);
        } else {
            return Result.failure(400,"注册失败，请重试！");
        }
    }
}
